<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class My_Controller extends Controller {
	var $CI;
	var $grpusrid;
	var $data;
	var $controller_name;
	var $action_name;
	var $test = 'test';
	
	function My_Controller(){
		parent::Controller();
                $this->CI =& get_instance();
		$this->CI->load->model($this->CI->config->item('folder_db').'/M_common', 'common', TRUE);
		//$this->grpusrid =  $this->CI->session->userdata('groupuserid');
//                if($this->session->userdata('login')==false){
//                    redirect('login');
//                }
    }
	
	function get_top_link(){
		$topLink = "<li>Loged As : <b>Agus Mulyanto</b></li>";
		return $topLink;
	}

	function get_top_menu(){
		$topMenu  ="<li><a href='".site_url()."/main'>Manajemen Barang</a></li>";
		$topMenu .="<li><a href='".site_url()."'>Pembelian Barang</a></li>";
		$topMenu .="<li><a href='".site_url()."'>Distributor</a></li>";
		$topMenu .="<li><a href='".site_url()."/login/logout'>Logout</a></li>";
		return $topMenu;
	}
	
	function get_right_style($content, $title){
		$style	= "<div class='box'><div class='box_title'>".$title."</div><div class='box_content'>";
		$style .= $content;
		$style .= "</div></div>";
		
		return $style;
	}
	
	function get_list_menu(){
		/*
			from sia -> fetch list of a lessons based on active semester and year of logged students or
			from sia -> fetch list of lesson which teach by a logged lecture
		*/
		
		$idMatakuliah = '1'; // fetch idMatakuliah from database 
		$content  = "Semester : Ganjil 2010/2010"; // fetch the active semester from setting
		$content .= "<p><ul>";
		$content .= "<li>".anchor('barang/','Manajemen Barang')."</li>";
		$content .= "<li>".anchor('pembelian/','Pembelian')."</li>";
                $content .= "<li>".anchor('kategori/scaffolding','Manajemen Kategori Barang',array('target'=>'_blank'))."</li>";
                $content .= "<li>".anchor('distributor/scaffolding','Distributor',array('target'=>'_blank'))."</li>";
		$content .= "</ul></p>";
		
		return $this->get_right_style($content, 'Perkuliahan'); 
	}
	
	
	public function render($dataContent='') {
                
		$this->controller_name 			= $this->CI->router->fetch_directory().$this->CI->router->fetch_class();
		$this->data 				= $dataContent;
 		$this->data['path']			= $this->controller_name;
 		$this->data['toplink']			= $this->get_top_link();
 		$this->data['topmenu']			= $this->get_top_menu();
 		$this->data['listMatakuliah']	= $this->get_list_menu();
 		$this->data['header']			= 'main/header';
 		$this->data['footer']			= 'main/footer';
                $this->CI->load->view("main/main_view", $this->data);
       
    }
}
?>
